﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Transport.Admin
{
    public partial class QLThongTinTaiXe : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btn_Update_Click(object sender, EventArgs e)
        {
            try
            {
                if (GridView_Driver.Rows.Count != 0)
                {
                    PhanCongControl PCctrl = new PhanCongControl();
                    TaiXeControl TXctrl = new TaiXeControl();

                    foreach (GridViewRow row in GridView_Driver.Rows)
                    {
                        CheckBox cb = (CheckBox)row.FindControl("cb_Select");
                        if (cb != null && cb.Checked)
                        {
                            string id = GridView_Driver.Rows[row.RowIndex].Cells[2].Text;
                            int count = PCctrl.count(id);
                            TXctrl.updateCount(id, count);
                        }
                    }
                }

                Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri);
            }
            catch (Exception)
            {
            }
        }

        protected void btn_UpdateAll_Click(object sender, EventArgs e)
        {
            try
            {
                TaiXeControl TXctrl = new TaiXeControl();

                TXctrl.updateCount();

                Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri);
            }
            catch (Exception)
            {
            }
        }

        protected void DetailsView_Driver_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
        {
            GridView_Driver.DataBind();
        }
    }
}